import React from "react";
import './TodoHeader.css';
import store from "../../../redux/store";
import {addTodoAction, requestAddTodo} from '../../../redux/reducers/todoReducer'
import {nanoid} from 'nanoid'
export default function TodoHeader() {
  let keyup = (e) => {
    //判断是否按下了回车键
    if(e.keyCode === 13){
      //新增
      store.dispatch(requestAddTodo(e.target.value));
    }
  }

  return (
    <div className="todo-header">
      <input type="text" placeholder="请输入你的任务名称，按回车键确认" onKeyUp={keyup} />
    </div>
  );
}
